<!DOCTYPE html>
<html lang="en">

<head>
    <title>Example</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        p {
            border: medium double black;
        }
    </style>
</head>

<body>
    <p id="textblock" class="fruit numbers">
        There are lots of different kinds of fruit - there are over 500 varieties of banana alone. By the time we add the countless
        types of apples, oranges, and other well-known fruit, we are faced with thousands of choices.
    </p>
    <pre id="results"></pre>
    <script>
        var results = document.getElementById('results');
        var elem = document.getElementById('textblock');

        results.innerHTML = "Element has lang attribute: " + elem.hasAttribute('lang') + "\n";
        results.innerHTML += "Adding lang attribute\n";
        elem.setAttribute('lang', 'en-US');
        results.innerHTML += "Attr value is: " + elem.getAttribute('lang') + "\n";
        results.innerHTML += "Set new value for lang attribute\n";
        elem.setAttribute('lang', 'en-UK');
        results.innerHTML += "Value is now: " + elem.getAttribute('lang') + "\n";
    </script>
</body>

</html>